#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n, k, t, xl, yd, xr, yu;
int x, y;

bool isin()
{
    if (x >= xl && x <= xr && y >= yd && y <= yu)
        return true;
    else
        return false;
}

int main()
{
    int staycount = 0;
    int passcount = 0;
    int tempcount = 0;
    vector<int> index;
    bool flag1 = false, flag2 = false;
    cin >> n >> k >> t >> xl >> yd >> xr >> yu;
    for (int i = 0; i < n; i++)
    {

        for (int j = 0; j < t; j++)
        {
            cin >> x >> y;
            if (isin())
            {
                if (!flag1)
                {
                    passcount++;
                    flag1 = true;
                }
                if (index.empty()){
                    tempcount++;
                }
                else if(!index.empty() && index.back()+1 == j){
                    tempcount++;
                }
                else{
                    tempcount = 0;
                }
                if (tempcount >= k && !flag2)
                {
                    staycount++;
                    flag2 = true;
                    continue;
                }
                if(!flag2) index.push_back(j);
            }
            else
                continue;
        }
        index.clear();
        flag1 = flag2 = false;
        tempcount = 0;
    }
    cout << passcount << endl;
    cout << staycount << endl;
    //system("pause");
    return 0;
}